class Solution {
public:
    bool isSymmetric(TreeNode* root) {
        if(!root) {
            return true;
        }
        return symm(root->left, root->right);
    }
    bool symm(TreeNode* left, TreeNode* right) {
        if(left == nullptr && right == nullptr) {
            return true;
        }
        if(left == nullptr || right == nullptr) {
            return false;
        }
        if(left->val != right->val) {
            return false;
        }
        return symm(left->left, right->right) && symm(left->right, right->left);
    }
};